//
//  HTWheelView.m
//  转盘练习
//
//  Created by whtapple on 3/21/16.
//  Copyright © 2016 whtapple. All rights reserved.
//

#import "HTWheelView.h"
#import "HTBtn.h"
#define rotateAngle(angle) ((angle)/180*M_PI)
@interface HTWheelView()
@property (weak, nonatomic) IBOutlet UIImageView *centerImageView;


@end
@implementation HTWheelView
//提供类方法
+(instancetype)wheelView{
    //从 XIB 加载
    HTWheelView *view = [[[NSBundle mainBundle] loadNibNamed:@"HTWheel" owner:nil options:nil] lastObject];
    return view;
}
-(void)awakeFromNib{
    CGFloat btnW = 68;
    CGFloat btnH = 143;
    CGFloat iconW = 40 *2;
    CGFloat iconH = 46 *2;
    UIImage *normalImage = [UIImage imageNamed:@"LuckyAstrology"];
    UIImage *selectedImage = [UIImage imageNamed:@"LuckyAstrologyPressed"];
    for (int index = 0; index < 12; index++) {
        HTBtn *btn = [[HTBtn alloc]init];
        btn.layer.frame = CGRectMake(self.centerImageView.center.x, self.centerImageView.center.y,btnW, btnH);
        btn.layer.anchorPoint =CGPointMake(0.5, 0);
        CGFloat angle = rotateAngle(index *30);
        btn.layer.transform = CATransform3DMakeRotation(angle, 0, 0, 1);
        CGRect imageFrame = CGRectMake(index*iconW, 0, iconW, iconH);
        
        
    }
}
@end
